package com.luguangtao.controller;

import com.github.pagehelper.PageInfo;
import com.luguangtao.api.ClientApi;
import com.luguangtao.bean.Clazz;
import com.luguangtao.bean.Student;
import com.luguangtao.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @类名: com.luguangtao.controller
 * @作者: lgt
 * @创建时间: 2019-12-07 09:11
 * @描述:
 **/
@RestController
@CrossOrigin
public class ClientController2 {

    @Autowired
    ClientApi clientApi;

    //登录
    @RequestMapping("login")
    public String login(String username,String password){
        String s = clientApi.login1(username, password);
        return s;
    }

    //注册
    @RequestMapping("regist")
    public String regist(User user){
        return clientApi.regist1(user);
    }

    //列表
    @RequestMapping("lists")
    public PageInfo<Student> lists(Integer pageNum,Integer pageSize){
        PageInfo<Student> studentPageInfo = clientApi.lists1(pageNum, pageSize);
        return studentPageInfo;
    }

    //获取班级
    @RequestMapping("getClazz")
    public List<Clazz> getClazz(){
        List<Clazz> clazz1 = clientApi.getClazz1();
        return clazz1;
    }

    //添加
    @RequestMapping("addStu")
    public int addStu(Student student){
       return clientApi.addStu1(student);
    }

    //删除
    @RequestMapping("del")
    public int del(Integer stuid){
       return clientApi.del1(stuid);
    }

    //回显
    @RequestMapping("getStudent")
    public Student getStudent(Integer stuid){
        Student student1 = clientApi.getStudent1(stuid);
        return student1;
    }

    //修改
    @RequestMapping("updateStu")
    public int updateStu(Student student){
        return clientApi.updateStu1(student);
    }
}
